import sqlite3

from flask import Flask,render_template

app = Flask(__name__)


@app.route('/')
def hello_world():  # put application's code here
    return render_template('index.html')  #引入template网页

@app.route('/movie')
def movie():
    datalist = []
    con = sqlite3.connect('movie.db')
    cur = con.cursor()
    sql = 'select * from movie250'
    data = cur.execute(sql)
    for item in data:
        datalist.append(item)
    con.close()
    return render_template('movie.html',movies=datalist)

@app.route('/score')
def score():
    scorelist = [] #评分
    countlist = [] #统计数量
    con = sqlite3.connect('movie.db')
    cur = con.cursor()
    sql = 'select score,count(score) from movie250 group by score '
    data = cur.execute(sql)
    for item in data:
        scorelist.append(item[0])
        countlist.append(item[1])
    con.close()
    return render_template('score.html',score=scorelist,count=countlist)

@app.route('/word')
def word():
    return render_template('word.html')

@app.route('/team')
def team():
    return render_template('team.html')

@app.route('/contact')
def contact():
    return render_template('contact.html')

if __name__ == '__main__':
    app.run()
